package common

import (
	"testing"

	"github.com/stackrox/rox/pkg/k8sutil"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

const (
	serviceAccountYAML = `apiVersion: v1
kind: ServiceAccount
metadata:
name: sensor
namespace: stackrox
labels:
app.kubernetes.io/name: stackrox
auto-upgrade.stackrox.io/component: "sensor"
imagePullSecrets:
- name: stackrox
`
	//#nosec G101 -- This is a false positive
	sensorTLSSecretYAML = `apiVersion: v1
kind: Secret
data:
  ca.pem: |
    LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUIwekNDQVhxZ0F3SUJBZ0lVRjBwTFZBcUVlc09qSW5FSnRQNUg0YlpZaTRjd0NnWUlLb1pJemowRUF3SXcKU0RFbk1DVUdBMVVFQXhNZVUzUmhZMnRTYjNnZ1EyVnlkR2xtYVdOaGRHVWdRWFYwYUc5eWFYUjVNUjB3R3dZRApWUVFGRXhReE1UUTJNRGMxT1RVME5qYzNOVGMwTXpZek5UQWVGdzB5TURBM01qa3hORFU0TURCYUZ3MHlOVEEzCk1qZ3hORFU0TURCYU1FZ3hKekFsQmdOVkJBTVRIbE4wWVdOclVtOTRJRU5sY25ScFptbGpZWFJsSUVGMWRHaHYKY21sMGVURWRNQnNHQTFVRUJSTVVNVEUwTmpBM05UazFORFkzTnpVM05ETTJNelV3V1RBVEJnY3Foa2pPUFFJQgpCZ2dxaGtqT1BRTUJCd05DQUFUY1oySHgvK2RqQ3NYL2VzSVo1RTFrOFRNell2cnJOYXhPQ00vWEp5L3F0eHdsCnZvUXJ4cWY2ck5COXBaWnBMVVFEYjBlUlFXM2YrekltSHdQSkRMTVpvMEl3UURBT0JnTlZIUThCQWY4RUJBTUMKQVFZd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVXdTZVd2bStDeE5TRHRzaWZLMGh4Z3VzdApVa2N3Q2dZSUtvWkl6ajBFQXdJRFJ3Q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ZEl3UVlNQmFBRk1FbmxyNXYKZ3NUVWc3YklueXRJY1lMckxWSkhNRXdHQTFVZEVRUkZNRU9DRDNObGJuTnZjaTV6ZEdGamEzSnZlSUlUYzJWdQpjMjl5TG5OMFlXTnJjbTk0TG5OMlk0SWJjMlZ1YzI5eUxYZGxZbWh2YjJzdWMzUmhZMnR5YjNndWMzWmpNQW9HCkNDcUdTTTQ5QkFNQ0EwY0FNRVFDSUJoRGN4WVFOUzZ6Y1lVQzltUDUwRDE5enVidkhIa0RSQ3JCUnQrM0pMRkoKQWlCUFROZDUzR1BIWFVjTmR1am5aV29iM1c1eTZvM25BaTl6dDdidzB6UHFSUT09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
  sensor-key.pem: |
    LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUtOL3d2cm5PSXY5Y1ZPT2U3YXA1U0V4VWg4ZVFMS2p3b2I3b1VqcnVoSXpvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFK2pXaGVCbjdOQVQxR1hKcWhzclZtMGo4eUE3c3JvT0hINnZsWmg1L0NTeTk1Zk1vLzlTSwpCTjdlc204YWkxTTM4Yy9yRjIxUTFGVDlyTkEvWDdSbWl3PT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=
metadata:
  labels:
    auto-upgrade.stackrox.io/component: sensor
  name: sensor-tls
  namespace: stackrox
type: Opaque
`
	//#nosec G101 -- This is a false positive
	centralTLSSecretYAML = `apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: central-tls
  namespace: stackrox
  labels:
    app.kubernetes.io/name: stackrox

  annotations:
    "helm.sh/hook": "pre-install"

data:
  ca-key.pem: LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSVBiR3FLUFJiQVFXbmxLaENnMndsb2ZKRjlkTk15NlJGK3MyWlprVmYvM09vQW9HQ0NxR1NNNDkKQXdFSG9V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UKblI4YWN6eGs2ZkoxeUtMTmR6UTZ1WUhoalpSQmRUTU5ndXBsWmRwZFBLRDU3czJOQ3MvbytsWmpzSmorQTNORApESktOSGU5YUtYVDBjd3JsR1JXdi8zSzdVT3Z3SGRHWmFRSURBUUFCTUEwR0NTcUdTSWIzRFFFQkN3VUFBNElCCkFRRFF1RTl4YTFiTkxpUjQzWWd6V1J4VHZHS0xKUUpadXpMcFJRYWxQWGIvSytNaUV0WStYcTBubWJGdXk2VkkKaUNWQmhHTENzSUJxazBvWVZ4TSt1UnpBdGR5SXFTSVZhMzNwRy9zRERseEFaSFJWdzJ6djBvNzNweklMYTlXbQp3ZjFvSS85RndYTXlGSTRzS2wyMDNrT2ZBdUhjZEl2S1lhM0g0M2dtVEg4WnAwV0FTd1F3ZG9hRXlxN2RDSE9TCjBXV0NtOWw2aXE4c0hqdnJRK3J2NFJ4K1J2TEt3Tk1nSVJWT2w5Sm9JWlc1TTNLR1BCYTdsYjJ2cFdqelFkSTIKRkJWTmxrL2dyYU9lVGdoc240K3pEYktWOUpFKzR0b2Nqb2ZDdjAyelBwZmRnNnV6MGdnSWdzcnlzdnpTcjZ6WgplUWU0L2NmZS82b2t6dVpZWjcyc1RWUkwKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
kind: Secret
metadata:
  labels:
    app.kubernetes.io/name: stackrox
  name: additional-ca-sensor
  namespace: stackrox
type: Opaque`
)

func mustGetObjFromYAML(t *testing.T, yaml string) *unstructured.Unstructured {
	obj, err := k8sutil.UnstructuredFromYAML(yaml)
	require.NoError(t, err)
	return obj
}

func TestFilterToOnlyCertObjects(t *testing.T) {
	serviceAccount := mustGetObjFromYAML(t, serviceAccountYAML)
	sensorTLS := mustGetObjFromYAML(t, sensorTLSSecretYAML)
	centralTLS := mustGetObjFromYAML(t, centralTLSSecretYAML)
	additionalCA := mustGetObjFromYAML(t, additionalCASensorYAML)
	filtered := []*unstructured.Unstructured{serviceAccount, sensorTLS, centralTLS, additionalCA}
	Filter(&filtered, CertObjectPredicate)
	assert.Equal(t, []*unstructured.Unstructured{sensorTLS}, filtered)
}

func TestFilterAdditionalCASecretObjects(t *testing.T) {
	serviceAccount := mustGetObjFromYAML(t, serviceAccountYAML)
	sensorTLS := mustGetObjFromYAML(t, sensorTLSSecretYAML)
	centralTLS := mustGetObjFromYAML(t, centralTLSSecretYAML)
	additionalCA := mustGetObjFromYAML(t, additionalCASensorYAML)
	filtered := []*unstructured.Unstructured{serviceAccount, sensorTLS, centralTLS, additionalCA}
	Filter(&filtered, AdditionalCASecretPredicate)
	assert.Equal(t, []*unstructured.Unstructured{additionalCA}, filtered)
}

func TestFilterNotAdditionalCASecretObjects(t *testing.T) {
	serviceAccount := mustGetObjFromYAML(t, serviceAccountYAML)
	sensorTLS := mustGetObjFromYAML(t, sensorTLSSecretYAML)
	centralTLS := mustGetObjFromYAML(t, centralTLSSecretYAML)
	additionalCA := mustGetObjFromYAML(t, additionalCASensorYAML)
	filtered := []*unstructured.Unstructured{serviceAccount, sensorTLS, centralTLS, additionalCA}
	Filter(&filtered, Not(AdditionalCASecretPredicate))
	assert.Equal(t, []*unstructured.Unstructured{serviceAccount, sensorTLS, centralTLS}, filtered)
}
